package com.xxb.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.xxb.entity.Admin;
import com.xxb.util.DBHelp;
import com.xxb.util.Rowmapper;

public class AdminDao {
	
	private DBHelp<Admin> db = new DBHelp<Admin>();
	
	public Admin login(String username,String userpwd){
		String sql = "select id,username,userpwd from t_admin where username=? and userpwd = ?";
		return db.queryObject(sql,new AdminRowmapper(), username,userpwd);
	}
	
	private class AdminRowmapper implements Rowmapper<Admin>{

		public Admin mapRow(ResultSet rs) throws SQLException {
			Admin admin = new Admin();
			
			admin.setId(rs.getInt("id"));
			admin.setUsername(rs.getString("username"));
			admin.setUserpwd(rs.getString("userpwd"));
			
			return admin;
		}
		
	}
}
